<template>
	<view>
		<view style="height: 18upx;"></view>
		<view class="card-view">
			<view class="card-title">注销当前账号</view>
			<view style="margin-top: 54upx;">
				<rich-text :nodes="content"></rich-text>
			</view>
		</view>
		<view style="height: 260upx;"></view>

		<FloatView>
			<view style="padding: 0 63upx;">
				<FloatButton @click="onSubmit">确认注销</FloatButton>
			</view>
		</FloatView>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				content: ''
			}
		},
		onLoad() {
			this.getConfig()
		},
		methods: {
			async onSubmit() {
				const boo = await uni.$util.showModal('确定注销该账号吗?')
				if (!boo) return
				uni.$util.showLoading()
				await uni.$api.updatePassword(this.formData).finally(uni.finally)
				uni.setStorageSync('token', '')
				await uni.$util.showSuccess()
				uni.reLaunch({
					url: '/pages/login/login'
				})
			},
			async getConfig() {
				uni.$util.showLoading()
				const res = await uni.$api.getConfig('CANCEL_ACCOUNT').finally(uni.finally)
				this.content = res.data.value
			}
		}
	}
</script>

<style scoped lang="scss">
	.card-view {
		width: 707rpx;
		margin: 0 auto;
		padding: 22upx 29upx;
		background: #FFFFFF;
		border-radius: 14rpx;

		.card-title {
			font-size: 36rpx;
			font-weight: 600;
			color: #2C1101;
		}
	}
</style>